﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection.Emit;
using System.Reflection;

namespace Fabs.Net.GIL
{
    public class Variable
    {
        public Variable()
        {
            Attributes = new List<FieldAttributes>();
        }

        public string Name { get; set; }
        public Type Type { get; set; }
        public string Value { get; set; }

        public List<FieldAttributes> Attributes { get; set; }

        public FieldBuilder Output { get; private set; }
        public void Compile(Class Parent)
        {
            var parent = Parent.Output;

            FieldAttributes attributes = Attributes[0];
            for (int i = 1; i < Attributes.Count; i++)
            {
                attributes |= Attributes[i];
            }

            Output = parent.DefineField(Name, Type, attributes);
            object value = Convert.ChangeType(Value, Type);
          //  Output.SetValue(Output,value );
        }

    }
}